package com.code.google.mdsc.model.impl;

import java.util.GregorianCalendar;
import java.util.List;

import com.code.google.mdsc.model.Booking;
import com.code.google.mdsc.model.Creditor;
import com.code.google.mdsc.model.Debtor;

/**
 * 
 */
public class BookingImpl implements Booking {

	private Creditor creditor = null;
	private List<Debtor> debtor = null;
	private GregorianCalendar dateOfBooking = null;

	/**
	 * 
	 * @param creditor
	 * @param debtor
	 * @param dateOfBooking
	 */
	public BookingImpl(Creditor creditor, List<Debtor> debtor,
			GregorianCalendar dateOfBooking) {
		this.creditor = creditor;
		this.debtor = debtor;
		this.dateOfBooking = dateOfBooking;
	}

	@Override
	public Creditor getCreditor() {
		return creditor;
	}

	@Override
	public GregorianCalendar getDateOfBooking() {
		return dateOfBooking;
	}

	@Override
	public List<Debtor> getDebtors() {
		return debtor;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((creditor == null) ? 0 : creditor.hashCode());
		result = prime * result
				+ ((dateOfBooking == null) ? 0 : dateOfBooking.hashCode());
		result = prime * result + ((debtor == null) ? 0 : debtor.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BookingImpl other = (BookingImpl) obj;
		if (creditor == null) {
			if (other.creditor != null)
				return false;
		} else if (!creditor.equals(other.creditor))
			return false;
		if (dateOfBooking == null) {
			if (other.dateOfBooking != null)
				return false;
		} else if (!dateOfBooking.equals(other.dateOfBooking))
			return false;
		if (debtor == null) {
			if (other.debtor != null)
				return false;
		} else if (!debtor.equals(other.debtor))
			return false;
		return true;
	}

}
